package www.openteam.com.ui.qualityCntrl;


import android.app.DatePickerDialog;
import android.app.ProgressDialog;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.support.v7.widget.AppCompatCheckBox;
import android.text.Editable;
import android.text.TextWatcher;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.DatePicker;
import android.widget.EditText;
import android.widget.ImageButton;
import android.widget.Spinner;
import android.widget.TextView;

import java.util.ArrayList;
import java.util.Calendar;
import java.util.List;

import butterknife.Bind;
import butterknife.ButterKnife;
import www.openteam.com.R;
import www.openteam.com.base.mBaseFragment;
import www.openteam.com.bean.FQCBadItem;
import www.openteam.com.bean.FQCCheckItem;
import www.openteam.com.bean.FQCCheckMan;
import www.openteam.com.bean.FQCCrMaMi;
import www.openteam.com.bean.FQCGoodsField;
import www.openteam.com.bean.FQCGoodsInspect;
import www.openteam.com.bean.FQCHalfGoodsInspect;
import www.openteam.com.bean.FQCSamplePlan;
import www.openteam.com.contract.qualityCntrl.FQCContract;
import www.openteam.com.presenter.qualityCntrl.FQCPresenter;
import www.openteam.com.tool.ToastUtil;

/**
 * A simple {@link Fragment} subclass.
 */
public class FQCFragment extends mBaseFragment<FQCPresenter>
        implements FQCContract.FQCView {


    @Bind(R.id.fqc_checkType)
    Spinner fqcCheckType;
    @Bind(R.id.search_bar)
    ImageButton searchBar;
    @Bind(R.id.fqc_CustName)
    TextView fqcCustName;
    @Bind(R.id.fqc_CustCode)
    TextView fqcCustCode;
    @Bind(R.id.fqc_ProductName)
    TextView fqcProductName;
    @Bind(R.id.fqc_ProductCode)
    TextView fqcProductCode;
    @Bind(R.id.fqc_ProductNo)
    TextView fqcProductNo;
    @Bind(R.id.fqc_Radson)
    TextView fqcRadson;
    @Bind(R.id.fqc_Specs)
    TextView fqcSpecs;
    @Bind(R.id.fqc_PlanNum)
    TextView fqcPlanNum;
    @Bind(R.id.fqc_BatchNo)
    TextView fqcBatchNo;
    @Bind(R.id.fqc_MeasureNum)
    TextView fqcMeasureNum;
    @Bind(R.id.fqc_CheckMan)
    Spinner fqcCheckManSpinner;
    @Bind(R.id.fqc_CheckDate)
    TextView fqcCheckDate;
    @Bind(R.id.search_bar2)
    ImageButton searchBar2;
    @Bind(R.id.fqc_SamplePlan)
    Spinner fqcSamplePlanSpinner;
    @Bind(R.id.fqc_TotalNum)
    Spinner fqcTotalNum;
    @Bind(R.id.fqc_RejectRate)
    TextView fqcRejectRate;
    @Bind(R.id.fqc_SpotCheck)
    TextView fqcSpotCheck;
    @Bind(R.id.fqc_CheckItem)
    Spinner fqcSpinnerCheckItem;
    @Bind(R.id.fqc_BadItem)
    Spinner fqcSpinnerBadItem;
    @Bind(R.id.fqc_BadProductDesc)
    EditText fqcBadProductDesc;
    @Bind(R.id.fqc_MRB)
    Spinner fqcMRB;
    @Bind(R.id.fqc_QualityNum)
    EditText fqcQualityNum;
    @Bind(R.id.fqc_ReworkNum)
    EditText fqcReworkNum;
    @Bind(R.id.fqc_Complement)
    EditText fqcComplement;
    @Bind(R.id.fqc_ScrapNum)
    EditText fqcScrapNum;
    @Bind(R.id.fqc_cr1)
    TextView fqcCr1;
    @Bind(R.id.fqc_cr2)
    TextView fqcCr2;
    @Bind(R.id.fqc_cr3)
    TextView fqcCr3;
    @Bind(R.id.fqc_OK)
    AppCompatCheckBox fqcOK;
    @Bind(R.id.fqc_mi1)
    TextView fqcMi1;
    @Bind(R.id.fqc_mi2)
    TextView fqcMi2;
    @Bind(R.id.fqc_mi3)
    TextView fqcMi3;
    @Bind(R.id.fqc_No)
    AppCompatCheckBox fqcNo;
    @Bind(R.id.fqc_ma1)
    TextView fqcMa1;
    @Bind(R.id.fqc_ma2)
    TextView fqcMa2;
    @Bind(R.id.fqc_ma3)
    TextView fqcMa3;
    @Bind(R.id.fqc_maOK)
    AppCompatCheckBox fqcMaOK;
    @Bind(R.id.fqc_result)
    EditText fqcResult;
    @Bind(R.id.fqc_cr4)
    EditText fqcCr4;
    @Bind(R.id.fqc_ma4)
    EditText fqcMa4;
    @Bind(R.id.fqc_mi4)
    EditText fqcMi4;
    @Bind(R.id.fqc_InputMan)
    EditText fqcInputMan;
    @Bind(R.id.fqc_InputDate)
    TextView fqcInputDate;
    @Bind(R.id.fqc_Vertifer)
    EditText fqcVertifer;
    @Bind(R.id.fqc_VertifDate)
    TextView fqcVertifDate;
    @Bind(R.id.fqc_CSVertifer)
    EditText fqcCSVertifer;
    @Bind(R.id.fqc_CSVertifDate)
    TextView fqcCSVertifDate;
    @Bind(R.id.fqc_QAVertifer)
    EditText fqcQAVertifer;
    @Bind(R.id.fqc_QAVertifDate)
    TextView fqcQAVertifDate;
    @Bind(R.id.fqc_GCVertifer)
    EditText fqcGCVertifer;
    @Bind(R.id.fqc_GCVertifDate)
    TextView fqcGCVertifDate;
    private int checkNum;
    private String TAG = getClass().getSimpleName();
    private List<FQCSamplePlan.DataBeanX.DataBean> samplePlandata;
    private ArrayList<String> checkItemList;
    public ISearch iSearch;
    private List<FQCCheckMan.DataBeanX.DataBean> checkMandata;
    private List<FQCCheckItem.DataBeanX.DataBean> checkItemData;
    private List<FQCBadItem.DataBeanX.DataBean> badItemData;
    FQCGoodsField.DataBeanX.DataBean dataBean1;

    public FQCFragment() {
        // Required empty public constructor
    }

    public void setiSearch(ISearch iSearch) {
        this.iSearch = iSearch;
    }

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
                             Bundle savedInstanceState) {
        // Inflate the layout for this fragment
        View view = inflater.inflate(R.layout.fragment_fqc, container, false);
        ButterKnife.bind(this, view);
        mPresenter = loadPresenter();
        initData();
        initView();
        initListener();
        return view;
    }

    @Override
    protected void initData() {
        if (mPresenter != null)
            mPresenter.attachView(this);
        checkItemList = new ArrayList<>();
        checkItemList.add("生产入库");
        checkItemList.add("存品检验");
        checkItemList.add("半成品检验");
        ArrayAdapter<String> checkItemAdapter = new ArrayAdapter<String>(getContext(),
                android.R.layout.simple_spinner_dropdown_item, checkItemList);
        checkItemAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
        fqcCheckType.setAdapter(checkItemAdapter);

        ArrayList<String> MBAList = new ArrayList<>();
        MBAList.add("特采");
        MBAList.add("全检");
        MBAList.add("返工");
        MBAList.add("其他");
        ArrayAdapter<String> MBAAdapter = new ArrayAdapter<String>(getContext(),
                android.R.layout.simple_spinner_dropdown_item, MBAList);
        MBAAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
        fqcMRB.setAdapter(MBAAdapter);
        if (null != dataBean1) {
            setGoodsYeild();//设置生产入库，判断
        }
    }

    private void setGoodsYeild() {

        fqcCustName.setText(dataBean1.getCustName());
        fqcCustCode.setText(dataBean1.getCustCode());
        fqcProductName.setText(dataBean1.getProductName());
        fqcProductCode.setText(dataBean1.getProductCode());
        fqcSpecs.setText(dataBean1.getSpecs());
        fqcProductNo.setText(dataBean1.getProductno());
        fqcPlanNum.setText(dataBean1.getPlanNumb());
        fqcRadson.setText(dataBean1.getRdsno());
        fqcBatchNo.setText(dataBean1.getBatchno());
        fqcMeasureNum.setText(dataBean1.getMeasureNum());
    }

    @Override
    protected void initListener() {

        searchBar.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                String code = fqcCheckType.getSelectedItem().toString();
                mPresenter.findCheckMan();
                switch (code) {
                    case "生产入库":
                        mPresenter.findGoodsFeild();
                        createProgressDialog(" 正在查询");
                        break;
                    case "存品检验":
                        mPresenter.findGoodsInspect();
                        createProgressDialog(" 正在查询");
                        break;
                    case "半成品检验":
                        mPresenter.findHalfGoodsInspect();
                        createProgressDialog(" 正在查询");
                        break;
                }

            }
        });

        searchBar2.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                mPresenter.findSamplePlan(80);
                mPresenter.findCheckItem();
            }
        });

        fqcSamplePlanSpinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
            @Override
            public void onItemSelected(AdapterView<?> adapterView, View view, int i, long l) {
                if (null != samplePlandata) {
                    String code = samplePlandata.get(i).getCode();
                    mPresenter.findSamplePlanResult(2030, code);
                }
            }

            @Override
            public void onNothingSelected(AdapterView<?> adapterView) {

            }
        });

        fqcCheckDate.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                fqcCheckDate.setTag(fqcCheckDate);
                selectCalendar(fqcCheckDate);
            }
        });

        fqcCSVertifDate.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                fqcCSVertifDate.setTag(fqcCSVertifDate);
                selectCalendar(fqcCSVertifDate);
            }
        });

        fqcGCVertifDate.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                fqcGCVertifDate.setTag(fqcGCVertifDate);
                selectCalendar(fqcGCVertifDate);
            }
        });

        fqcQAVertifDate.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                fqcQAVertifDate.setTag(fqcQAVertifDate);
                selectCalendar(fqcQAVertifDate);
            }
        });

        fqcInputDate.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                fqcInputDate.setTag(fqcInputDate);
                selectCalendar(fqcInputDate);
            }
        });

        fqcVertifDate.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                fqcVertifDate.setTag(fqcVertifDate);
                selectCalendar(fqcVertifDate);
            }
        });
    }

    public void selectCalendar(final TextView v) {
        Calendar calendar = Calendar.getInstance();
        DatePickerDialog datePickerDialog = new DatePickerDialog(getContext(), new DatePickerDialog.OnDateSetListener() {
            @Override
            public void onDateSet(DatePicker view, int year, int monthOfYear, int dayOfMonth) {
                v.setText(year + "-" + (monthOfYear + 1) + "-" + dayOfMonth);
            }
        }, calendar.get(Calendar.YEAR), calendar.get(Calendar.MONTH), calendar.get(Calendar.DAY_OF_MONTH));
        datePickerDialog.show();
    }

    public void createProgressDialog(String content) {
        if (mProgressDialog == null) {
            mProgressDialog = new ProgressDialog(getContext());
        }
        mProgressDialog.setMessage(content);
        mProgressDialog.show();


    }

    @Override
    protected void initView() {

    }

    @Override
    protected void otherViewClick(View view) {

    }

    @Override
    protected FQCPresenter loadPresenter() {
        return new FQCPresenter();
    }

    @Override
    public void onDestroyView() {
        super.onDestroyView();
        ButterKnife.unbind(this);
    }

    @Override
    public void onRefresh() {

    }

    @Override
    public void findGoodsFeildSuccess(FQCGoodsField fqcGoodsField) {
        mProgressDialog.dismiss();
        if (iSearch != null) {
            if (null == fqcGoodsField.getData().getData()) {
                ToastUtil.showToast(getContext(), "暂时没有数据");
            } else {
                iSearch.goodsYeild(fqcGoodsField);
            }
        }
    }

    @Override
    public void findGoodsInspectSuccess(FQCGoodsInspect fqcGoodsInspect) {
        mProgressDialog.dismiss();
        if (iSearch != null) {
            if (null == fqcGoodsInspect.getData().getData()) {
                ToastUtil.showToast(getContext(), "暂时没有数据");
            } else {
                iSearch.goodsInspect(fqcGoodsInspect);
            }
        }
    }

    @Override
    public void findHalfGoodsInspectSuccess(FQCHalfGoodsInspect fqcHalfGoodsInspect) {
        mProgressDialog.dismiss();
        if (iSearch != null) {
            if (null == fqcHalfGoodsInspect.getData().getData()) {
                ToastUtil.showToast(getContext(), "暂时没有数据");
            } else {
                iSearch.halfGoodsInspect(fqcHalfGoodsInspect);
            }
        }
    }

    @Override
    public void findSamplePlan(FQCSamplePlan fqcSamplePlan) {
        samplePlandata = fqcSamplePlan.getData().getData();
        ArrayList<String> samplePlanList = new ArrayList<>();

        for (FQCSamplePlan.DataBeanX.DataBean dataBean : samplePlandata) {
            samplePlanList.add(dataBean.getCode());
        }
        ArrayAdapter<String> samplePlanAdapter = new ArrayAdapter<String>(getContext(),
                android.R.layout.simple_spinner_dropdown_item, samplePlanList);
        samplePlanAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
        fqcSamplePlanSpinner.setAdapter(samplePlanAdapter);
    }

    @Override
    public void findSamplePlanResult(FQCSamplePlan fqcSamplePlan) {
        FQCSamplePlan.DataBeanX.DataBean dataBean = fqcSamplePlan.getData().getData().get(0);
        int cr = Integer.valueOf(dataBean.getCR());
        int mi = Integer.valueOf(dataBean.getMI());
        int ma = Integer.valueOf(dataBean.getMA());
        checkNum = dataBean.getCheckNum();
        fqcCr1.setText(cr + "");
        mPresenter.findElement(cr, checkNum, "cr");
        fqcMa1.setText(ma + "");
        mPresenter.findElement(ma, checkNum, "ma");
        fqcMi1.setText(mi + "");
        mPresenter.findElement(mi, checkNum, "mi");
    }

    @Override
    public void findElement(FQCCrMaMi fqcCrMaMi, String mark) {
        int passNum = fqcCrMaMi.getData().getData().get(0).getPassNum();
        switch (mark) {
            case "cr":
                fqcCr2.setText(passNum + "");
                fqcCr4.addTextChangedListener(new TextWatcher() {
                    @Override
                    public void beforeTextChanged(CharSequence charSequence, int i, int i1, int i2) {

                    }

                    @Override
                    public void onTextChanged(CharSequence charSequence, int i, int i1, int i2) {

                    }

                    @Override
                    public void afterTextChanged(Editable editable) {
                        fqcCr3.setText(editable.toString());
                        //输入的值
                        int cr, mi, ma;
                        if (fqcCr3.getText().toString().isEmpty()) {
                            fqcCr3.setText("0");
                        }
                        if (fqcMi3.getText().toString().isEmpty()) {
                            fqcMi3.setText("0");
                        }
                        if (fqcMa3.getText().toString().isEmpty()) {
                            fqcMa3.setText("0");
                        }
                        cr = Integer.valueOf(fqcCr3.getText().toString());
                        mi = Integer.valueOf(fqcMi3.getText().toString());
                        ma = Integer.valueOf(fqcMa3.getText().toString());
                        //合格的标准值
                        int cr1, mi1, ma1;
                        if (fqcCr2.getText().toString().isEmpty()) {
                            fqcCr2.setText("0");
                        }
                        if (fqcMi2.getText().toString().isEmpty()) {
                            fqcMi2.setText("0");
                        }
                        if (fqcMa2.getText().toString().isEmpty()) {
                            fqcMa2.setText("0");
                        }
                        cr1 = Integer.valueOf(fqcCr2.getText().toString());
                        mi1 = Integer.valueOf(fqcMi2.getText().toString());
                        ma1 = Integer.valueOf(fqcMa2.getText().toString());
                        //所有输入值小于等于合格值即为合格
                        Log.e(TAG, "afterTextChanged:fqcCr3 cr: " + cr + "-cr1-" + cr1 + ",-mi1-" + mi1 + "-mi-" + mi + ",-ma1-" + ma1 + "-ma-" + ma);
                        if (cr <= cr1 && mi <= mi1 && ma <= ma1) {
                            fqcOK.setChecked(true);
                            fqcNo.setChecked(false);
                        } else {
                            fqcOK.setChecked(false);
                            fqcNo.setChecked(true);
                        }
                    }
                });
                break;
            case "ma":
                fqcMa2.setText(passNum + "");
                fqcMa4.addTextChangedListener(new TextWatcher() {
                    @Override
                    public void beforeTextChanged(CharSequence charSequence, int i, int i1, int i2) {

                    }

                    @Override
                    public void onTextChanged(CharSequence charSequence, int i, int i1, int i2) {
                        fqcMa3.setText(charSequence.toString());
                        Log.e(TAG, "onTextChanged: " + charSequence.toString());

                    }

                    @Override
                    public void afterTextChanged(Editable editable) {
                        Log.e(TAG, "afterTextChanged: editable:" + editable.toString() + "text:" + fqcMa3.getText().toString());
                        //输入的值
                        int cr, mi, ma;
                        if (fqcCr3.getText().toString().isEmpty()) {
                            fqcCr3.setText("0");
                        }
                        if (fqcMi3.getText().toString().isEmpty()) {
                            fqcMi3.setText("0");
                        }
                        if (fqcMa3.getText().toString().isEmpty()) {
                            fqcMa3.setText("0");
                        }
                        cr = Integer.valueOf(fqcCr3.getText().toString());
                        mi = Integer.valueOf(fqcMi3.getText().toString());
                        ma = Integer.valueOf(fqcMa3.getText().toString());
                        //合格的标准值
                        int cr1, mi1, ma1;
                        if (fqcCr2.getText().toString().isEmpty()) {
                            fqcCr2.setText("0");
                        }
                        if (fqcMi2.getText().toString().isEmpty()) {
                            fqcMi2.setText("0");
                        }
                        if (fqcMa2.getText().toString().isEmpty()) {
                            fqcMa2.setText("0");
                        }
                        cr1 = Integer.valueOf(fqcCr2.getText().toString());
                        mi1 = Integer.valueOf(fqcMi2.getText().toString());
                        ma1 = Integer.valueOf(fqcMa2.getText().toString());
                        //所有输入值小于等于合格值即为合格
                        Log.e(TAG, "afterTextChanged:fqcMa3 cr: " + cr + "-cr1-" + cr1 + ",-mi1-" + mi1 + "-mi-" + mi + ",-ma1-" + ma1 + "-ma-" + ma);
                        if (cr <= cr1 && mi <= mi1 && ma <= ma1) {
                            fqcOK.setChecked(true);
                            fqcNo.setChecked(false);
                        } else {
                            fqcOK.setChecked(false);
                            fqcNo.setChecked(true);
                        }
                    }
                });
                break;
            case "mi":
                fqcMi2.setText(passNum + "");
                fqcMi4.addTextChangedListener(new TextWatcher() {
                    @Override
                    public void beforeTextChanged(CharSequence charSequence, int i, int i1, int i2) {

                    }

                    @Override
                    public void onTextChanged(CharSequence charSequence, int i, int i1, int i2) {

                    }

                    @Override
                    public void afterTextChanged(Editable editable) {
                        fqcMi3.setText(editable.toString());
                        //输入的值
                        int cr, mi, ma;
                        if (fqcCr3.getText().toString().isEmpty()) {
                            fqcCr3.setText("0");
                        }
                        if (fqcMi3.getText().toString().isEmpty()) {
                            fqcMi3.setText("0");
                        }
                        if (fqcMa3.getText().toString().isEmpty()) {
                            fqcMa3.setText("0");
                        }
                        cr = Integer.valueOf(fqcCr3.getText().toString());
                        mi = Integer.valueOf(fqcMi3.getText().toString());
                        ma = Integer.valueOf(fqcMa3.getText().toString());
                        //合格的标准值
                        int cr1, mi1, ma1;
                        if (fqcCr2.getText().toString().isEmpty()) {
                            fqcCr2.setText("0");
                        }
                        if (fqcMi2.getText().toString().isEmpty()) {
                            fqcMi2.setText("0");
                        }
                        if (fqcMa2.getText().toString().isEmpty()) {
                            fqcMa2.setText("0");
                        }
                        cr1 = Integer.valueOf(fqcCr2.getText().toString());
                        mi1 = Integer.valueOf(fqcMi2.getText().toString());
                        ma1 = Integer.valueOf(fqcMa2.getText().toString());
                        //所有输入值小于等于合格值即为合格
                        Log.e(TAG, "afterTextChanged:fqcMi3 cr: " + cr + "-cr1-" + cr1 + ",-mi1-" + mi1 + "-mi-" + mi + ",-ma1-" + ma1 + "-ma-" + ma);
                        if (cr <= cr1 && mi <= mi1 && ma <= ma1) {
                            fqcOK.setChecked(true);
                            fqcNo.setChecked(false);
                        } else {
                            fqcOK.setChecked(false);
                            fqcNo.setChecked(true);
                        }
                    }
                });
                break;
        }
        if (fqcOK.isChecked()) {
            fqcMRB.setSelected(false);
        } else {
            fqcMRB.setSelected(true);
        }
    }

    /**
     * 生产入库
     *
     * @param dataBean
     */
    public void onGoodsField(FQCGoodsField.DataBeanX.DataBean dataBean) {
        dataBean1 = dataBean;
    }

    public void onGoodsInspect(FQCGoodsInspect data) {

    }

    public void onHalfGoodsInspect(FQCHalfGoodsInspect data) {

    }


    @Override
    public void findCheckItem(FQCCheckItem fqcCheckItem) {
        checkItemData = fqcCheckItem.getData().getData();
        ArrayList<String> checkItemList = new ArrayList<>();

        for (FQCCheckItem.DataBeanX.DataBean dataBean : checkItemData) {
            checkItemList.add(dataBean.getItemName());
        }
        ArrayAdapter<String> checkItemAdapter = new ArrayAdapter<String>(getContext(),
                android.R.layout.simple_spinner_dropdown_item, checkItemList);
        checkItemAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
        fqcSpinnerCheckItem.setAdapter(checkItemAdapter);

        fqcSpinnerCheckItem.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
            @Override
            public void onItemSelected(AdapterView<?> adapterView, View view, int i, long l) {
                FQCCheckItem.DataBeanX.DataBean dataBean = checkItemData.get(i);
                mPresenter.findBadItem(dataBean.getItemID());
            }

            @Override
            public void onNothingSelected(AdapterView<?> adapterView) {

            }
        });

    }

    @Override
    public void findCheckMan(FQCCheckMan fqcCheckMan) {
        checkMandata = fqcCheckMan.getData().getData();
        ArrayList<String> checkManList = new ArrayList<>();

        for (FQCCheckMan.DataBeanX.DataBean dataBean : checkMandata) {
            checkManList.add(dataBean.getName());
        }
        ArrayAdapter<String> checkManAdapter = new ArrayAdapter<String>(getContext(),
                android.R.layout.simple_spinner_dropdown_item, checkManList);
        checkManAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
        fqcCheckManSpinner.setAdapter(checkManAdapter);
    }

    @Override
    public void findBadItem(FQCBadItem fqcBadItem) {
        badItemData = fqcBadItem.getData().getData();
        ArrayList<String> badItemList = new ArrayList<>();

        for (FQCBadItem.DataBeanX.DataBean dataBean : badItemData) {
            badItemList.add(dataBean.getName());
        }
        ArrayAdapter<String> badItemAdapter = new ArrayAdapter<String>(getContext(),
                android.R.layout.simple_spinner_dropdown_item, badItemList);
        badItemAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
        fqcSpinnerBadItem.setAdapter(badItemAdapter);
    }

    @Override
    public void fail(String msg) {
        Log.e(TAG, "fail: " + msg);
    }

    public interface ISearch {

        void goodsYeild(FQCGoodsField fqcGoodsField);

        void goodsInspect(FQCGoodsInspect fqcGoodsInspect);

        void halfGoodsInspect(FQCHalfGoodsInspect fqcHalfGoodsInspect);
    }


}
